[RF] Add RooONNXFunction: ONNX-backed neural function support for RooFit#21928
Merged
guitargeek merged 4 commits intoroot-project:masterfrom Apr 21, 2026
Merged
[RF] Add RooONNXFunction: ONNX-backed neural function support for RooFit#21928guitargeek merged 4 commits intoroot-project:masterfrom
guitargeek merged 4 commits intoroot-project:masterfrom
Conversation
3e86637 to
bdab5d2
Compare
Test Results 21 files 21 suites 3d 4h 17m 32s ⏱️ Results for commit 65eaa9e. ♻️ This comment has been updated with latest results. |
79e32ab to
861c74e
Compare
08e980b to
a84d0a7
Compare
a84d0a7 to
5b45216
Compare
vgvassilev
approved these changes
Apr 19, 2026
Member
vgvassilev
left a comment
There was a problem hiding this comment.
LGTM but I'd rather have somebody else to look at this too.
5b45216 to
bb33802
Compare
This ensures that we use a consistent GEMM functions by wrapping the GEMM call in the pullback also with the wrapper.
This is helpful if such a test depends on input files that are created by another test.
Add some `constexpr` info in input tensor structure to the generated
code, inside the same namespace as the session struct.
It looks for example like this:
```c++
constexpr std::array<SingleDim, 1> dim_start{SingleDim{1}};
constexpr std::array<SingleDim, 1> dim_limit{SingleDim{1}};
constexpr std::array<SingleDim, 1> dim_delta{SingleDim{1}};
constexpr std::array<TensorDims, 3> inputTensorDims{
makeDims(dim_start),
makeDims(dim_limit),
makeDims(dim_delta)
};
```
This is helpful for validating inputs when using the SOFIE-generated
code without knowing much about about the original ONNX file, and is the
case for the use in RooFit.
Introduce `RooONNXFunction`, a new `RooAbsReal` implementation that enables native inference of ONNX models within RooFit. The class loads ONNX graphs, JIT-compiles them via TMVA SOFIE at runtime, and evaluates them efficiently with support for automatic differentiation through Clad. Key features: * Seamless integration of parametric neural networks into RooFit workflows * Runtime ONNX-to-C++ code generation via SOFIE (no hard dependency at link time, the SOFIE usage is an implementation detail) * Support for analytic gradients (codegen + Clad) * Support for serialization to RooWorkspace by embedding the ONNX payload as a binary blob A unit test is also implemented. This development unlocks new use cases such as neural simulation-based inference (SBI), likelihood surrogate models, and ML-driven parametric models. This commit addresses an item on the ROOT plan of work 2026.
bb33802 to
65eaa9e
Compare
dpiparo
approved these changes
Apr 21, 2026
lmoneta
approved these changes
Apr 21, 2026
Member
lmoneta
left a comment
There was a problem hiding this comment.
LGTM!
Thank you Jonas for impelmenting this very nice addition in RooFit supporting SBI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce
RooONNXFunction, a newRooAbsRealimplementation that enables native inference of ONNX models within RooFit. The class loads ONNX graphs, JIT-compiles them via TMVA SOFIE at runtime, and evaluates them efficiently with support for automatic differentiation through Clad.Key features:
link time, the SOFIE usage is an implementation detail)
payload as a binary blob
A unit test is also implemented.
This development unlocks new use cases such as neural simulation-based inference (SBI), likelihood surrogate models, and ML-driven parametric models.
This commit addresses an item on the ROOT plan of work 2026.